package test;

import java.util.HashMap;

import people.Person.Name;
import people.professor.Professor;
import people.student.Student;
import people.student.StudentFactory;
import uniManager.UniManager;
import course.AbstractCourseType;
import course.Course;
import course.CourseFactory;
import course.FinalExamCourseType;
import course.SimpleTestType;
import course.group.GroupCourseType;

public class GetCourseTypesForStudents extends AbstractTestCase {

	private static final UniManager um = UniManager.INSTANCE;
	private static final StudentFactory sf = StudentFactory.INSTANCE;
	private static final CourseFactory cf = CourseFactory.INSTANCE;
	
	private Course c1;
	private SimpleTestType st1;
	private FinalExamCourseType f1;
	private GroupCourseType gt1;
	private Student s1, s2;
	private Professor professor;
	private HashMap<AbstractCourseType, Integer> options1 = new HashMap<AbstractCourseType, Integer>();
	private HashMap<AbstractCourseType, Integer> options2 = new HashMap<AbstractCourseType, Integer>();
	
	@Override
	public void test() throws Exception {
		setup();
		
		System.out.println("---------------------------------------------------------------");
		System.out.println("-------Get LVAs and more for Student-(START)-------------------");
		System.out.println();
		
		System.out.println("Register Student 1 for c1 (group 1)");
		um.registerStudent(c1, s1, options1);
		System.out.println("Register Student 2 for c1 (group 2)");
		um.registerStudent(c1, s2, options2);
		System.out.println();
		
		System.out.println("Data for Studen s1:");
		for(Course c : um.getCoursesForStudent(s1)){
			System.out.println("[Hauptkurs]: "+c);
			for(AbstractCourseType t : c.getTypes()){
				if(t.isStudentRegistered(s1))
					System.out.println("["+t+"] : "+t.getInformationForStudent(s1));
				else
					System.out.println("not registered for: "+t);
			}
		}
		System.out.println();
		
		System.out.println("Data for Studen s2:");
		for(Course c : um.getCoursesForStudent(s2)){
			System.out.println("[Hauptkurs]: "+c);
			for(AbstractCourseType t : c.getTypes()){
				if(t.isStudentRegistered(s2))
					System.out.println("["+t+"] : "+t.getInformationForStudent(s2));
				else
					System.out.println("not registered for: "+t);
			}
		}
		System.out.println();
		
		System.out.println("-------Get LVAs and more for Student-(END)----------------------");
		System.out.println("---------------------------------------------------------------");
	}

	private void setup() throws Exception{
		professor = new Professor(new Name("walter", "black"));
		c1 = cf.createCourse("Die letzte LVA.", professor);
		um.addCourse(c1);
		
		s1 = sf.addNewStudent(4111, new Name("Jig", "jig"));
		s2 = sf.addNewStudent(4112, new Name("Saw", "saw"));
		
		st1 = new SimpleTestType(c1.getCourseID(),"Test 1", professor);
		gt1 = new GroupCourseType(c1.getCourseID(),"Haskell (Live) Arbeit", professor, null, null, null);
		f1 = new FinalExamCourseType(c1.getCourseID(),"THE PLF", professor, null, null, null);
		
		gt1.addGroup(1, "DIENSTAG -10% BEIM BAUMAX", professor);
		gt1.addGroup(2, "NOT DIENSTAG", professor);
		
		um.addCourseType(c1, st1);
		um.addCourseType(c1, gt1);
		um.addCourseType(c1, f1);
		
		options1.put(gt1, 1);
		options2.put(gt1, 2);
	}
}
